

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Sections &mdash; PHPRtfLite v1.x documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.x',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="PHPRtfLite v1.x documentation" href="index.html" />
    <link rel="next" title="Formatting" href="formatting.html" />
    <link rel="prev" title="Document settings" href="document-settings.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="formatting.html" title="Formatting"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="document-settings.html" title="Document settings"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">PHPRtfLite v1.x documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="sections">
<h1>Sections<a class="headerlink" href="#sections" title="Permalink to this headline">¶</a></h1>
<p>Sections margins and paper width and height can be specified in the same way like for the RTF document. Sections margin and paper width/height will overwrite RTF document margins and paper width/heigth.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See <em>Document settings</em> &gt; <a class="reference internal" href="document-settings.html#doc-settings-page-margins"><em>Page margins</em></a> and <em>Document settings</em> &gt; <a class="reference internal" href="document-settings.html#doc-settings-page-size"><em>Page size</em></a>.</p>
</div>
<div class="section" id="section-columns">
<h2>Section columns<a class="headerlink" href="#section-columns" title="Permalink to this headline">¶</a></h2>
<p>Section text can be spreaded over columns (all having the same width):</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="c1">// text will spreaded over 3 columns</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setNumberOfColumns</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span>
</pre></div>
</div>
<p>Another way to define section columns with particular column widths:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="c1">// text will spreaded over 3 columns (widths are: 1cm, 2cm, and 3cm)</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setColumnWidths</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">));</span>
</pre></div>
</div>
<p>Separate your section columns with a line, if you like to:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="c1">// text will spreaded over 3 columns (widths are: 1cm, 2cm, and 3cm)</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setColumnWidths</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">));</span>
<span class="c1">// line between section columns</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setLineBetweenColumns</span><span class="p">();</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Lorem ipsum&#39;</span><span class="p">);</span>
</pre></div>
</div>
<p>There is also the posibility to add space between the columns:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="c1">// text will spreaded over 3 columns (widths are: 1cm, 2cm, and 3cm)</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setColumnWidths</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">));</span>
<span class="c1">// 0.2cm of space between section columns</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setSpaceBetweenColumns</span><span class="p">(</span><span class="mf">0.2</span><span class="p">);</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Lorem ipsum&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="page-breaks">
<h2>Page breaks<a class="headerlink" href="#page-breaks" title="Permalink to this headline">¶</a></h2>
<p>Explizit page break:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Lorem ipsum&#39;</span><span class="p">);</span>
<span class="c1">// insert a page break</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">insertPageBreak</span><span class="p">();</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Text on the next page&#39;</span><span class="p">);</span>
</pre></div>
</div>
<p>To prevent a page break, if possible, you can do the following:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Lorem ipsum&#39;</span><span class="p">);</span>
<span class="c1">// prevent page break</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setNoBreak</span><span class="p">();</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Text on the next page&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="hyperlinks">
<h2>Hyperlinks<a class="headerlink" href="#hyperlinks" title="Permalink to this headline">¶</a></h2>
<p>To add a hyperlink:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeText</span><span class="p">(</span><span class="s1">&#39;Lorem ipsum: &#39;</span><span class="p">);</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">writeHyperLink</span><span class="p">(</span><span class="s1">&#39;http://lipsum.lipsum.com/&#39;</span><span class="p">,</span> <span class="s1">&#39;Lorem ipsum&#39;</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="borders">
<h2>Borders<a class="headerlink" href="#borders" title="Permalink to this headline">¶</a></h2>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>
<span class="c1">// some bootstraping here</span>

<span class="nv">$border</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">PHPRtfLite_Border</span><span class="p">(</span>
    <span class="nv">$rtf</span><span class="p">,</span>                                       <span class="c1">// PHPRtfLite instance</span>
    <span class="k">new</span> <span class="nx">PHPRtfLite_Border_Format</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;#00FF00&#39;</span><span class="p">),</span> <span class="c1">// left border: 2pt, green color</span>
    <span class="k">new</span> <span class="nx">PHPRtfLite_Border_Format</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;#FFFF00&#39;</span><span class="p">),</span> <span class="c1">// top border: 1pt, yellow color</span>
    <span class="k">new</span> <span class="nx">PHPRtfLite_Border_Format</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;#FF0000&#39;</span><span class="p">),</span> <span class="c1">// right border: 2pt, red color</span>
    <span class="k">new</span> <span class="nx">PHPRtfLite_Border_Format</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;#0000FF&#39;</span><span class="p">)</span>  <span class="c1">// bottom border: 1pt, blue color</span>
<span class="p">);</span>
<span class="nv">$section</span> <span class="o">=</span> <span class="nv">$rtf</span><span class="o">-&gt;</span><span class="na">addSection</span><span class="p">();</span>
<span class="c1">// set section border</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setBorder</span><span class="p">(</span><span class="nv">$border</span><span class="p">);</span>

<span class="c1">// set one border format for top, left, right, and bottom</span>
<span class="nv">$section</span><span class="o">-&gt;</span><span class="na">setBorders</span><span class="p">(</span><span class="k">new</span> <span class="nx">PHPRtfLite_Border_Format</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;#00FF00&#39;</span><span class="p">));</span>
</pre></div>
</div>
<p>Read more about creating borders here: <a class="reference internal" href="formatting.html#borders"><em>Borders</em></a>.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Sections</a><ul>
<li><a class="reference internal" href="#section-columns">Section columns</a></li>
<li><a class="reference internal" href="#page-breaks">Page breaks</a></li>
<li><a class="reference internal" href="#hyperlinks">Hyperlinks</a></li>
<li><a class="reference internal" href="#borders">Borders</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="document-settings.html"
                        title="previous chapter">Document settings</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="formatting.html"
                        title="next chapter">Formatting</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/sections.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="formatting.html" title="Formatting"
             >next</a> |</li>
        <li class="right" >
          <a href="document-settings.html" title="Document settings"
             >previous</a> |</li>
        <li><a href="index.html">PHPRtfLite v1.x documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, sigmaz.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
  </body>
</html>